//https://blog.csdn.net/zl1zl2zl3/article/details/81357146
import { PureComponent } from 'react';
import {
    Row,
    Col,
    Form,
    Input,
    Button,
    Modal,
} from 'antd';

const FormItem = Form.Item;


//查看表单
@Form.create()
class ViewForm extends PureComponent {
    static defaultProps = {
        handleViewModalVisible: () => {},
    values: {},
};

constructor(props) {
    super(props);
		console.log(props);
    this.state = {
        formVals: {
            group_id: props.values.group_id,
            group_name: props.values.group_name,
            parent_id: props.values.parent_id,
        },
    };


}



renderContent = (formVals) => {
    const { form } = this.props;

    return (
        <Form  layout="vertical" hideRequiredMark>



                <Row gutter={{ md: 8, lg: 24, xl: 48 }}>

                    <Col  md={24} sm={48}>
                    <FormItem  label="组名称">
                        {form.getFieldDecorator('group_name', {
                        rules: [{ required: true, message: '请输入组名称！', min: 1 }],
                        initialValue: formVals.group_name,
                        })(<Input  readOnly placeholder="请输入" />)}
                    </FormItem>
                    </Col>



                    <Col  md={12} sm={24} style={{display: 'none'}}>
                    <FormItem  label="父组Id">
                        {form.getFieldDecorator('parent_id', {
                        rules: [{ required: true, message: '请输入至少五个字符的父组Id！', min: 5 }],
                        initialValue: formVals.parent_id,
                        })(<Input  readOnly placeholder="请输入" />)}
                    </FormItem>
                    </Col>


                        </Row>

    </Form>
);

};



render() {
    const { viewModalVisible, handleViewModalVisible, values } = this.props;

    return (
        <Modal
    width={800}
    height={800}
    bodyStyle={{ padding: '32px 40px 48px' }}
    destroyOnClose
    title="查看"
    visible={viewModalVisible}
    onCancel={() => handleViewModalVisible(false, values)}
    footer={<Button key="back" onClick = { () => handleViewModalVisible(false, values) }>取消</Button>}
>

    {this.renderContent(values)}
</Modal>
);
}

}

export default ViewForm;


